local sk__qiluan = fk.CreateSkill {

  name = "sk__qiluan",

  tags = {  },

}



sk__qiluan:addEffect(fk.TurnEnd, {
  name = "sk__qiluan",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__qiluan.name) and not target.dead and
      table.find(player.room:getOtherPlayers(target), function(p)
        return not target:isProhibited(p, Fk:cloneCard("slash"))
      end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room:getOtherPlayers(target), function(p)
      return not target:isProhibited(p, Fk:cloneCard("slash"))
    end), Util.IdMapper)
    local to = room:askForChoosePlayers(player, targets, 1, 1, "#sk__qiluan-choose::"..target.id, sk__qiluan.name, true, true)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:useVirtualCard("slash", nil, target, room:getPlayerById(event:getCostData(self)), sk__qiluan.name, true)
    if not player.dead then
      local n = #player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 999, function(e)
        return not (e.data.reason == "damage" and e.data.damageEvent.isVirtualDMG)
      end, Player.HistoryTurn)
      if n > 0 then
        player:drawCards(n, sk__qiluan.name)
      end
    end
  end,
})

return sk__qiluan